package com.glory.dgcpcpda.adapter;

import android.view.View;
import android.widget.CheckBox;
import android.widget.FrameLayout;
import android.widget.RadioButton;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.dgcpcpda.R;
import com.glory.dgcpcpda.base.MyApp;
import com.glory.dgcpcpda.entity.AlarmStepEntity;
import com.glory.dgcpcpda.entity.QCformEntity;
import com.pda.platform.ui.ui_pdaplatform.dialog.FreeUI_GeneralPop;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_PopUtils;

import java.util.ArrayList;
import java.util.List;

public class ItemLinesAdapter extends BaseQuickAdapter<QCformEntity.QCFORMINFO.ITEMLINESINFO, BaseViewHolder> {

    private List<String> mResultList;
    private FreeUI_GeneralPop mResultPop;
    public ItemLinesAdapter(@Nullable ArrayList<QCformEntity.QCFORMINFO.ITEMLINESINFO> data) {
        super(R.layout.item_lines, data);
        mResultList = new ArrayList<>();
        mResultList.add("OK");
        mResultList.add("NG");
        mResultList.add("NA");
    }

    @Override
    protected void convert(BaseViewHolder helper, QCformEntity.QCFORMINFO.ITEMLINESINFO item) {
        helper.setText(R.id.tvItemName,item.getITEMNAME());
        helper.setText(R.id.tvItemDesc,item.getITEMDESC());
        FrameLayout flResultList = helper.getView(R.id.flResultList);
        flResultList.setOnClickListener(view -> {
            mResultPop = FreeApi_PopUtils.getNormalPop(MyApp.app, flResultList.getWidth(), mResultList, helper.getView(R.id.ivResultArrow), (code, i) -> {
                item.setRESULT(code);
                helper.setText(R.id.tvResult,code);
            });
            FreeApi_PopUtils.setArrowShow(helper.getView(R.id.ivResultArrow));
            mResultPop.showAsDropDown(flResultList, 0, 0);
        });
    }
}
